package testpak;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;

public class NewClas {
	public static void main(String args[]){
		System.out.println("hellolaosong!");
		Map<String,Object> m = new HashMap<String,Object>();
		if(m.get("k")!=null){
			System.out.println(m.get("k"));
		}else{
			System.out.println("getK is null");
		}
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection con = DriverManager.getConnection("jdbc:oracle:thin:@10.172.12.42:1521:audiclub", "audi_club", "audi_clubdbuser");
			/*SID: audidb
			用户名：audi_ade
			密码： audi­_adedbuser*/

			//Connection con = DriverManager.getConnection("jdbc:oracle:thin:@10.172.12.42:1521:audidb", "audi_ade", "audi­_adedbuser");
			System.out.println(con);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//NewClas n = new NewClas();
		//System.out.println(n.bulidActionClass());
		//System.out.println(n.covrUpur("Album"));
		//System.out.println(n.bulidBean());
		
	}
	public String bulidActionClass(){
		String className = "Topic";
		String objName = covrUpur(className);
		String Service =objName+"Service";
		String id = objName+"Id";
		StringBuffer act = new StringBuffer();
		String action = className+"Action";
		act.append("@SuppressWarnings(\"serial\")\n");
		act.append("@Scope(\"prototype\")\n");
		act.append("@Controller(\"auti.action."+action+"\")\n");
		act.append("public class "+className+"Action"+" extends BaseAction{\n");
		act.append("@Autowired\n");
		act.append("protected "+className+"Service "+Service+";\n");
		act.append("String "+id+";\n");
		act.append("public String query(){\n");
		act.append("return \"result\";\n");
		act.append("}\n");
		act.append("public String add(){\n");
		act.append(className+" "+covrUpur(className)+" = new "+className+"();\n");
		act.append(Service+".add("+objName+");\n");
		act.append("return null;\n");
		act.append("}\n");
		
		act.append("public String modify(){\n");
		act.append(" return null;\n");
		act.append("}\n");
		act.append("public String del(){\n");
		 
		
		act.append(Service+".del(Integer.parseInt("+id+"));\n");
		act.append(" return null;\n");
		act.append("}\n");
		act.append("}\n");
		
		
		return act.toString();
	}
	public String covrUpur(String s){
		/*char c = s.charAt(0);
		c = Character.toLowerCase(c);
		s = s.replaceFirst("1", "a");*/
		String s_ = s.substring(0,1);
		String s2 = s_.toLowerCase();
		String s3 = s.replaceFirst(s_, s2);
		return s3;
	}
	public String bulidBean(){
		String className = "Video";
		//video_id,,video_name,circle_id
		String[] filed = new String[]{"videoId","urlAddress","videoName","circle"};
		StringBuffer bean = new StringBuffer();
		bean.append("private String "+filed[0]+";\n");
		bean.append("private String "+filed[1]+";\n");
		bean.append("private String "+filed[2]+";\n");
		bean.append("private String "+filed[3]+";\n");
		bean.append("\n");
		return bean.toString();
	}

}
